package com.itheima.server.service;

import com.itheima.dubbo.api.UserApi;
import com.itheima.server.interceptor.UserHolder;
import com.tanhua.autoconfig.vo.HuanXinUserVo;
import com.tanhua.model.domain.User;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class HuanxinService {

    @DubboReference
    private UserApi userApi;

    /**
     * 作用：查找当前用户的环信账号与密码
     * @return
     */
    public HuanXinUserVo findHuanXinUser() {
        Long userId = UserHolder.getId();
        User user = userApi.findById(userId);
        HuanXinUserVo userVo = new HuanXinUserVo();
        userVo.setUsername(user.getHxUser());
        userVo.setPassword(user.getHxPassword());
        return userVo;
    }
}
